﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SqliteDriver
{
	/*
		Class to hold constants
		SqlCommand is taken by ADO
	*/
	class Cmd
	{
		// [Specialise: define extension commands]
		public const String ScriptLinq = "DOLINQ";
		public const String ScriptClass = "ORM";
		public const String DisplayHeldTable = "DISPLAYTABLE"; // this may be moved to the main framework
		public const String PragmaIntegrity = "INTEGRITY";
		public const String Encoding = "ENCODING";

		// "dangerous" commands
		public const String CreateTable = "CREATETABLE";
		public const String ResetAuto = "RESETAUTO";

		// builder. creates a custom command and sets the action
		public static DbView.Command MakeCommand(String commandString)
		{
			// default is to make an extension command that populates a table
			DbView.Command command = new DbView.Command(DbView.Commands.Cmnd.Extension, commandString, DbView.Command.CommandAction.poptable);
			// [Specialise: override extension command action ]
			if (command.Name == Cmd.CreateTable ||
				command.Name == Cmd.ResetAuto ||
				command.Name == Cmd.ScriptClass ||
				command.Name == Cmd.CreateTable
				)
				command.Action = DbView.Command.CommandAction.driveraction;
			if (command.Name == Cmd.ScriptLinq
				)
				command.Action = DbView.Command.CommandAction.text;
			
			return command;
		}

		public static void ResetHelp(DbView.CommandHelpRepository helpRepository)
		{
			helpRepository.SetHelp(MakeCommand(ScriptLinq), "Create a CSharp class from the table for access by Linq");
			helpRepository.SetHelp(MakeCommand(ResetAuto), "Check and reset the auto-increment value.");
			helpRepository.SetHelp(MakeCommand(ScriptClass), "Create a POCO class from the table for use with an ORM framework");
		}
	}
	class CmdParam
	{
		// [Specialise: add defined parameters ]
		public const String FkName = "FKNAME";
		public const String FkTable = "FKTABLE";
		public const String PkTable = "PKTABLE";
		public const String FkField = "FKFIELD";
		public const String PkField = "PKFIELD";
	}
}
